//
//  changeStoreMessageVm.swift
//  Pods
//
//  Created by eme on 2017/3/28.
//
//

import SwiftyJSON
import RxSwift
import Result
import ModelProtocol

class changeStoreMessageVm{
    
    let backMessage = PublishSubject<Bool>()
    
    let changeMessage = PublishSubject<String>()
    
    let error = PublishSubject<MikerError>()
    
    let disposeBag = DisposeBag()
    
    init(){
        
        let request = changeMessage.map{ message in
            return MineApi.changeStroeMessage(glshop: message)
            }.shareReplay(1)
        
        let response = request.emeRequestApiForRegJson().shareReplay(1)
        
        response.subscribe(onNext:{[unowned self] (result) in
            switch result{
            case.success(_):
                
                self.backMessage.onNext(true)
                
            case .failure(let error):
                
                self.error.onNext(error)
                
            }
            
        }).addDisposableTo(disposeBag)
        
    }
    
    
}
